package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlWsabsence;
import com.ruoyi.sl.service.ISlWsabsenceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车间扣发绩效系数Controller
 * 
 * @author admin
 * @date 2024-06-10
 */
@RestController
@RequestMapping("/sl/wsabsence")
public class SlWsabsenceController extends BaseController
{
    @Autowired
    private ISlWsabsenceService slWsabsenceService;

    /**
     * 查询车间扣发绩效系数列表
     */
    @PreAuthorize("@ss.hasPermi('sl:wsabsence:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlWsabsence slWsabsence)
    {
        startPage();
        List<SlWsabsence> list = slWsabsenceService.selectSlWsabsenceList(slWsabsence);
        return getDataTable(list);
    }

    /**
     * 导出车间扣发绩效系数列表
     */
    @PreAuthorize("@ss.hasPermi('sl:wsabsence:export')")
    @Log(title = "车间扣发绩效系数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlWsabsence slWsabsence)
    {
        List<SlWsabsence> list = slWsabsenceService.selectSlWsabsenceList(slWsabsence);
        ExcelUtil<SlWsabsence> util = new ExcelUtil<SlWsabsence>(SlWsabsence.class);
        util.exportExcel(response, list, "车间扣发绩效系数数据");
    }

    /**
     * 获取车间扣发绩效系数详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:wsabsence:query')")
    @GetMapping(value = "/{absenceId}")
    public AjaxResult getInfo(@PathVariable("absenceId") Long absenceId)
    {
        return success(slWsabsenceService.selectSlWsabsenceByAbsenceId(absenceId));
    }

    /**
     * 新增车间扣发绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:wsabsence:add')")
    @Log(title = "车间扣发绩效系数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlWsabsence slWsabsence)
    {
        slWsabsence.setCreateBy(getUsername());
        return toAjax(slWsabsenceService.insertSlWsabsence(slWsabsence));
    }

    /**
     * 修改车间扣发绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:wsabsence:edit')")
    @Log(title = "车间扣发绩效系数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlWsabsence slWsabsence)
    {
        slWsabsence.setUpdateBy(getUsername());
        return toAjax(slWsabsenceService.updateSlWsabsence(slWsabsence));
    }

    /**
     * 删除车间扣发绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:wsabsence:remove')")
    @Log(title = "车间扣发绩效系数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{absenceIds}")
    public AjaxResult remove(@PathVariable Long[] absenceIds)
    {
        return toAjax(slWsabsenceService.deleteSlWsabsenceByAbsenceIds(absenceIds));
    }
}
